﻿Imports System.Data.OleDb
Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack = False Then
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("travelConnectionString").ConnectionString)
            Dim SqlString As String = "Select * From Hotels"
            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            oleDbConn.Open()
            Dim dataReader = cmd.ExecuteReader()
            GridView1.DataSource = dataReader
            GridView1.DataBind()
        End If

        If User.IsInRole("Administrator") Then
            PlaceHolder1.Visible = True
        Else : PlaceHolder1.Visible = False
        End If


    End Sub
    Protected Function getStars(ByVal stars As Integer)
        Dim retval As String
        retval = ""
        For i = 1 To stars
            retval = retval + "*"
        Next
        Return retval


    End Function

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("travelConnectionString").ConnectionString)
        Dim SqlString As String = "Select * From Hotels Where Location = @F1"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", Trim(TextBox1.Text))
        oleDbConn.Open()
        Dim dataReader = cmd.ExecuteReader()
        GridView1.DataSource = dataReader
        GridView1.DataBind()
    End Sub
End Class